package com.azt.provider.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.azt.api.pojo.SignUp;
import com.azt.api.pojo.req.SignUpReq;
import com.azt.api.service.MeetingService;
import com.azt.api.service.SignUpService;
import com.azt.model.page.Pagination;
import com.azt.provider.mapper.SignUpMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Service
@Transactional
public class SignUpServiceImpl implements SignUpService{
	
@Autowired
private SignUpMapper signUpMapper;
@Autowired
private MeetingService meetingService;
	
	@Override
	public Pagination getSignUpPage(int pageNo, int pageSize, Map<String, String> searchMap) {
		Page<Object> startPage = PageHelper.startPage(pageNo, pageSize);
		List<SignUp> signList = signUpMapper.querySignUpsBySQL(searchMap);
		Pagination p = new Pagination(startPage, signList);
		p.setList(signList);
		p.setParams(searchMap);
		return p;
	}


	@Override
	public void delSignById(Integer id) {
		signUpMapper.deleteByPrimaryKey(id);
	}


	@Override
	public void saveOrUpdateSignUp(SignUp signup) {
		if(signup.getId()!=null){
			signUpMapper.updateByPrimaryKeySelective(signup);
		}else{
			signUpMapper.insertSelective(signup);
		}
	}


	@Override
	public SignUp getSignUpById(Integer id) {
		return signUpMapper.getSignUpById(id);
	}


	@Override
	public SignUp getSignUpByseatNo(String seatNo) {
		return signUpMapper.getSignUpByseatNo(seatNo);
	}

	@Override
	public void save(SignUpReq req) {
		SignUp signUp = new SignUp();
		BeanUtils.copyProperties(req, signUp);
		signUpMapper.insert(signUp);
	}
}
